// bzoj2176
// run: $exec < input
#include <iostream>
#include <string>

void print(std::string const & s, int p, int l)
{
	for (int i = 0; i < l; i++)
		std::cout << s[p + i];
	std::cout << '\n';
}

bool cmp(char a, char b)
{
	return (unsigned char)a < (unsigned char)b;
}

int minimum_representation(std::string const & s, int l)
{
	int i = 0, j = 1;
	for (int t = 0; i < l && j < l; ) {
		if (cmp(s[i], s[j])) j++;
		else if (cmp(s[j], s[i])) i = j, j++;
		else {
			for (t = 0; t < l; t++) {
				if (cmp(s[i + t], s[j + t])) { j += t; break; }
				else if (cmp(s[j + t], s[i + t])) { i = j; j = (j + t) % l; break; } // this line is important
			}
			if (t == l) break;
		}
	}
	return i;
}

int main()
{
	// std::ios::sync_with_stdio(false); FIXME add this line get runtime error
	int n;
	std::string s;
	std::cin >> n;
	std::getline(std::cin, s);
	std::getline(std::cin, s);
	s += s;
	int p = minimum_representation(s, n);
	print(s, p, n);
}

